package com.example.demo.controller;

import com.example.demo.commons.SessionManager;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/{appCode}")
public class DemoController {

    private final SessionManager sessionManager;

    public DemoController(final SessionManager sessionManager) {
        this.sessionManager = sessionManager;
    }

    @GetMapping("/demo")
    public String getCode(@PathVariable final String appCode) {
        return "Hello " + sessionManager.getSessionObject().getOpenid() + "@" + appCode;
    }
}
